﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using MinhTuan;

public partial class usercontrol_other_loginCallback : System.Web.UI.UserControl,ICallbackEventHandler
{
    public string Callback;
    protected void Page_Load(object sender, EventArgs e)
    {
        
        Callback = Page.ClientScript.GetCallbackEventReference(this, "arg", "GetValuefromServer", "context", true);
        if (!IsPostBack)
        { 
             String[] user = Session["user"].ToString().Split(',');
            //this.litUser.Text = "( " + user[1] + " )";
             if (Convert.ToInt32(user[0]) > 0)
             {
                 login.Visible = false;
                 litersign.Text = "<a href='http://localhost:2011/didong/users/thoat.html'>LogOut</a>";
                 ltuser.Text = "<a href='http://localhost:2011/didong/users/thoat.html'>Xin Chào: [" + user[1] + "]</a>";
               
             }
             else {
                 login.Visible = true;
                 litersign.Text = "<a href='http://localhost:2011/didong/users/dangky.html'>Sing In</a>";
             
             }
             if (Session["Shopcart"] == null)
             {
                 this.linkcart.Text = "Giỏ hàng rỗng";
             }
             else
             {
                 int count = int.Parse(Session["count"].ToString());
                 this.linkcart.Text = "Có " + count + " sản phẩm";
                 this.linkcart.NavigateUrl = "http://localhost:2011/didong/Shoping/giohang.html";
             }
        }
       
    }
    public string GetCallbackResult()
    {
        return Callback;
    }
    public void RaiseCallbackEvent(string eventArgument)
    {

        String[] str = eventArgument.Split('|');
        Members mymember = Members.Member_login(str[0], str[1]);
        int id = mymember.Members_Id;
        if (id > 0)
        {
            Callback = "1";
            Session["user"] = mymember.Members_Id + "," + mymember.Members_Name + ",false";
            litersign.Text = "<a href='http://localhost:2011/didong/users/thoat.html'>LogOut</a>";
            ltuser.Text = "<a href='http://localhost:2011/didong/users/thoat.html'>Xin Chào: [" + mymember.Members_Name + "]</a>";

        }
        else Callback = "0"; ;
    }
    protected void linkOut_Click(object sender, EventArgs e)
    {
        Session["user"] = "-1,gues,true";
        Response.Redirect("http://localhost:2011/didong");
    }
}
